// This example shows how to read values of 4 items at once, and display them. // // Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html . // OPC client and subscriber examples in C# on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-CSharp . // Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own // a commercial license in order to use Online Forums, and we reply to every post. using System; using System.Diagnostics; using OpcLabs.BaseLib.OperationModel; using OpcLabs.EasyOpc.DataAccess; namespace DocExamples.DataAccess.Xml { class ReadMultipleItemValues { public static void Main1Xml() { // Instantiate the client object. var client = new EasyDAClient(); ValueResult[] valueResults = client.ReadMultipleItemValues("http://opcxml.demo-this.com/XmlDaSampleServer/Service.asmx", new DAItemDescriptor[] { "Dynamic/Analog Types/Double", "Dynamic/Analog Types/Double[]", "Dynamic/Analog Types/Int", "Static/Analog Types/Int" }); for (int i = 0; i < valueResults.Length; i++) { ValueResult valueResult = valueResults[i]; Debug.Assert(!(valueResult is null)); if (valueResult.Succeeded) Console.WriteLine($"valueResults[{i}].Value: {valueResult.Value}"); else Console.WriteLine($"valueResults[{i}] *** Failure: {valueResult.ErrorMessageBrief}"); } } // Example output: // //valueResults[0].Value: 50 //valueResults[1].Value: System.Double[] //valueResults[2].Value: 100 //valueResults[3].Value: 12345 } }
' This example shows how to read values of 4 items at once, and display them. ' ' Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html . ' OPC client and subscriber examples in VB.NET on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-VBNET . ' Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own ' a commercial license in order to use Online Forums, and we reply to every post. Imports OpcLabs.BaseLib.OperationModel Imports OpcLabs.EasyOpc.DataAccess Namespace DataAccess.Xml Partial Friend Class ReadMultipleItemValues Public Shared Sub Main1Xml() ' Instantiate the client object. Dim client = New EasyDAClient() Dim valueResults() As ValueResult = client.ReadMultipleItemValues("http://opcxml.demo-this.com/XmlDaSampleServer/Service.asmx", New DAItemDescriptor() {"Dynamic/Analog Types/Double", "Dynamic/Analog Types/Double[]", "Dynamic/Analog Types/Int", "Static/Analog Types/Int"}) For i = 0 To valueResults.Length - 1 Dim valueResult As ValueResult = valueResults(i) Debug.Assert(valueResult IsNot Nothing) If valueResult.Succeeded Then Console.WriteLine($"valueResults[{i}].Value: {valueResult.Value}") Else Console.WriteLine($"valueResults[{i}] *** Failure: {valueResult.ErrorMessageBrief}") End If Next i End Sub ' Example output: ' 'valueResults[0].Value: 50 'valueResults[1].Value System.Double[] 'valueResults[2].Value: 100 'valueResults[3].Value: 12345 End Class End Namespace
# This example shows how to read values of 4 items at once, and display them. # # Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html . # OPC client and subscriber examples in Python on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-Python . # Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own # a commercial license in order to use Online Forums, and we reply to every post. # The QuickOPC package is needed. Install it using "pip install opclabs_quickopc". import opclabs_quickopc # Import .NET namespaces. from OpcLabs.EasyOpc import * from OpcLabs.EasyOpc.DataAccess import * from OpcLabs.EasyOpc.DataAccess.OperationModel import * from OpcLabs.EasyOpc.OperationModel import * # Instantiate the client object. client = EasyDAClient() valueResults = IEasyDAClientExtension.ReadMultipleItemValues(client, ServerDescriptor('http://opcxml.demo-this.com/XmlDaSampleServer/Service.asmx'), [ DAItemDescriptor('Dynamic/Analog Types/Double'), DAItemDescriptor('Dynamic/Analog Types/Double[]'), DAItemDescriptor('Dynamic/Analog Types/Int'), DAItemDescriptor('Static/Analog Types/Int') ]) for i, valueResult in enumerate(valueResults): assert valueResult is not None if valueResult.Succeeded: print('valueResults[', i, '].Value: ', valueResult.Value, sep='') else: print('valueResults[', i, '] *** Failure: ', valueResult.ErrorMessageBrief, sep='') # Example output: # #valueResults[0].Value: 0.00125125888851588 #valueResults[1].Value: System.Double[] #valueResults[2].Value: -0.993968485238202 #valueResults[3].Value: 0
Copyright © 2004-2024 CODE Consulting and Development, s.r.o., Plzen. All rights reserved.
Documentation Home, Send Documentation Feedback. Technical Support